home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-16 | 2.0 KB | 100 lines | [TEXT/CWIE] |
- //====
- // ISpElementView.cp
- //=====
-
- #include "ISpElementView.h"
- #include "ISpTestGlobals.h"
- #include <TextUtils.h>
- #include "ISpPPTestTools.h"
-
- ISpElementView::ISpElementView(LStream *inStream):LOffscreenView(inStream)
- {
- StartIdling();
- }
-
- ISpElementView::~ISpElementView()
- {
- }
-
- ISpElementView *ISpElementView::CreateISpElementViewStream(LStream *inStream)
- {
- return (new ISpElementView(inStream));
- }
-
-
- void ISpElementView::SpendTime(const EventRecord &inMacEvent)
- {
- Refresh();
- UpdatePort();
- }
-
-
- void ISpElementView::DrawSelf()
- {
- if (gElement == nil) { return; }
-
- Rect r;
- Str255 theString;
-
- CalcLocalFrameRect(r);
- r.left += 10;
-
- EraseRect(&r);
-
- OSStatus pollStatus;
- UInt32 state;
-
- pollStatus = ISpElement_GetSimpleState(gElement, &state);
- ISpElementInfo info;
- ISpElement_GetInfo(gElement, &info);
-
- MoveTo(r.left, r.top + 15);
- DrawString("\pGlobal Error Code: ");
- NumToString(gStatus, theString);
- DrawString(theString);
-
- MoveTo(r.left, r.top + 30);
- DrawString("\pPoll Error Code: ");
- NumToString(pollStatus, theString);
- DrawString(theString);
-
- MoveTo(r.left, r.top + 45);
- DrawString("\pData: ");
- UInt32ToHexString(state, theString);
- DrawString(theString);
-
- {
- const rectWidth = 100;
- Rect maxRect = {2,0,11,rectWidth};
- Rect progRect = maxRect;
- float percent = state;
- percent /= 0xffffffff;
-
- progRect.right = rectWidth * percent;
-
- OffsetRect(&maxRect, r.left, r.top + 47);
- OffsetRect(&progRect, r.left, r.top + 47);
-
- ::FrameRect(&maxRect);
- ::PaintRect(&progRect);
- }
-
- MoveTo(r.left, r.top + 75);
- DrawString("\pElement Num: ");
- UInt32ToHexString((unsigned long) gElement, theString);
- DrawString(theString);
-
- MoveTo(r.left, r.top + 90);
- DrawString("\pElement Label: ");
- UInt32ToFourByte(info.theLabel, theString);
- DrawString(theString);
-
- MoveTo(r.left, r.top + 105);
- DrawString("\pElement Kind: ");
- UInt32ToFourByte(info.theKind, theString);
- DrawString(theString);
-
- MoveTo(r.left, r.top + 120);
- DrawString("\pElement Name: ");
- DrawString(info.theString);
- }